﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using Studio77.SuperLink.Entities;
using System.IO.IsolatedStorage;

namespace Studio77.SuperLink.Core
{
    public class StageManager
    {
        public static StageManager Instance = new StageManager();

        public bool TurnMoka = true;

        /// <summary>
        /// 关卡数
        /// </summary>
        public const int ClassStageCount = 28;

        private StageManager()
        {
            InitStageInfos();
        }

        //keys
        private const string STAGE_DATA_KEY = "stageDataKey";
        private const string IS_PLAY_BACKGROUND_KEY = "isPlayBackgroundKey";
        private const string IS_PLAY_SOUND_KEY = "isPlaySoundKey";
        private const string LAUNCH_COUNT = "launchCount";
        private const string MARKET_COMMENT = "marketComment";

        /// <summary>
        /// 存储游戏关卡数据
        /// key: StageType + Index
        /// </summary>
        public Dictionary<string, StageData> StageDatas { get; set; }

        public Dictionary<string, StageInfo> StageInfos { get; set; }

        public string CurrentStageType { get; set; }

        public int CurrentStageIndex { get; set; }

        private bool isPlaySound = true;
        /// <summary>
        /// 
        /// </summary>
        public bool IsPlaySound
        {
            get
            {
                return isPlaySound;
            }
            set
            {
                isPlaySound = value;
                IsolatedStorageSettings.ApplicationSettings[IS_PLAY_SOUND_KEY] = isPlaySound;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isPlayBackground = true;
        /// <summary>
        /// 
        /// </summary>
        public bool IsPlayBackground
        {
            get
            {
                return isPlayBackground;
            }
            set
            {
                isPlayBackground = value;
                IsolatedStorageSettings.ApplicationSettings[IS_PLAY_BACKGROUND_KEY] = isPlayBackground;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private int launchCount = 0;
        public int LaunchCount
        {
            get
            {
                return launchCount;
            }
            set
            {
                launchCount = value;
                IsolatedStorageSettings.ApplicationSettings[LAUNCH_COUNT] = launchCount;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        private bool isCommented = false;
        public bool IsCommented
        {
            get
            {
                return isCommented;
            }
            set
            {
                isCommented = value;
                IsolatedStorageSettings.ApplicationSettings[MARKET_COMMENT] = isCommented;
                IsolatedStorageSettings.ApplicationSettings.Save();
            }
        }

        public void Init()
        {
            if (IsolatedStorageSettings.ApplicationSettings.Contains(LAUNCH_COUNT))
            {
                launchCount = (int)IsolatedStorageSettings.ApplicationSettings[LAUNCH_COUNT];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains(MARKET_COMMENT))
            {
                isCommented = (bool)IsolatedStorageSettings.ApplicationSettings[MARKET_COMMENT];
            }


            if (IsolatedStorageSettings.ApplicationSettings.Contains(IS_PLAY_SOUND_KEY))
            {
                isPlaySound = (bool)IsolatedStorageSettings.ApplicationSettings[IS_PLAY_SOUND_KEY];
            }
            if (IsolatedStorageSettings.ApplicationSettings.Contains(IS_PLAY_BACKGROUND_KEY))
            {
                isPlayBackground = (bool)IsolatedStorageSettings.ApplicationSettings[IS_PLAY_BACKGROUND_KEY];
            }
            if (IsolatedStorageSettings.ApplicationSettings.Contains(STAGE_DATA_KEY))
            {
                StageDatas = IsolatedStorageSettings.ApplicationSettings[STAGE_DATA_KEY] as Dictionary<string, StageData>;
            }
            else
            {
                // 初始化
                StageDatas = new Dictionary<string, StageData>();
                StageDatas.Add("1_1", new StageData());
                StageDatas.Add("2_1", new StageData());
                StageDatas.Add("3_1", new StageData());
                SaveStageDatas();
            }

        }

        private void InitStageInfos()
        {
            StageInfos = new Dictionary<string, StageInfo>();
            int index = 1;
            StageInfo info = null;

            #region 休闲模式

            //休闲模式
            string stageTypePre = "1_";

            index = 1;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 4,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 2;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 5,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 3;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 5,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 4;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 6,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 5;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 6,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 6;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 7,
                CardStartIndex = 5,
                Column = 4,
                Row = 6,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 7;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 6,
                CardStartIndex = 5,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 8;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 6,
                CardStartIndex = 10,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 9;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 6,
                CardStartIndex = 10,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 10;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 6,
                CardStartIndex = 14,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 11;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 6,
                CardStartIndex = 3,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 12;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 6,
                CardStartIndex = 6,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 13;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 6,
                CardStartIndex = 6,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 14;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 6,
                CardStartIndex = 8,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 15;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 8,
                CardStartIndex = 8,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 16;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 8,
                CardStartIndex = 0,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 17;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.None,
                CardChangeRange = 8,
                CardStartIndex = 12,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 18;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 9,
                CardStartIndex = 2,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 19;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 9,
                CardStartIndex = 10,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 20;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 10,
                CardStartIndex = 10,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 21;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 11,
                CardStartIndex = 9,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 22;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 11,
                CardStartIndex = 6,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 23;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 11,
                CardStartIndex = 0,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 24;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 11,
                CardStartIndex = 0,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 25;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 12,
                CardStartIndex = 8,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 26;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 12,
                CardStartIndex = 8,
                Column = 6,
                Row = 9,
                GameSeconds = 75
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 27;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 12,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 80
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 28;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 13,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 80
            };
            StageInfos.Add(stageTypePre + index, info);

            #endregion

            #region 普通模式

            //休闲模式
            stageTypePre = "2_";

            index = 1;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 8,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 2;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 8,
                CardStartIndex = 3,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 3;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 10,
                CardStartIndex = 10,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 4;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 10,
                CardStartIndex = 5,
                Column = 6,
                Row = 9,
                GameSeconds = 60
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 5;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 10,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 6;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 10,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 7;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 11,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 8;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 11,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 9;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 12,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 10;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.None,
                CardChangeRange = 13,
                CardStartIndex = 7,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 11;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 13,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 12;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 13,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 13;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 13,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 14;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 14,
                CardStartIndex = 3,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 15;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 14,
                CardStartIndex = 6,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 16;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 14,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 17;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 15,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 18;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 15,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 19;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 14,
                CardStartIndex = 5,
                Column = 8,
                Row = 12,
                GameSeconds = 85
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 20;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 15,
                CardStartIndex = 3,
                Column = 8,
                Row = 12,
                GameSeconds = 85
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 21;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 16,
                CardStartIndex = 3,
                Column = 8,
                Row = 12,
                GameSeconds = 90
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 22;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 17,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 95
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 23;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 18,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 95
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 24;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 19,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 95
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 25;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 8,
                CardStartIndex = 8,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 26;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 9,
                CardStartIndex = 8,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 27;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 10,
                CardStartIndex = 5,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 28;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 11,
                CardStartIndex = 5,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            #endregion

            #region 挑战模式

            //休闲模式
            stageTypePre = "3_";

            index = 1;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 17,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 2;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 17,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 3;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 17,
                CardStartIndex = 3,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 4;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 17,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 5;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 17,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 6;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 17,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 7;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 18,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 8;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 18,
                CardStartIndex = 2,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 9;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 19,
                CardStartIndex = 1,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 10;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 19,
                CardStartIndex = 1,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 11;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.None,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 12;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 13;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 100
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 14;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 105
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 15;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 8,
                Row = 12,
                GameSeconds = 120
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 16;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 13,
                CardStartIndex = 0,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 17;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 14,
                CardStartIndex = 5,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 18;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 14,
                CardStartIndex = 6,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 19;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 14,
                CardStartIndex = 5,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 20;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 14,
                CardStartIndex = 2,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 21;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.TopBottom,
                CardChangeRange = 15,
                CardStartIndex = 3,
                Column = 10,
                Row = 15,
                GameSeconds = 170
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 22;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 16,
                CardStartIndex = 3,
                Column = 10,
                Row = 15,
                GameSeconds = 180
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 23;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.None,
                CardChangeRange = 17,
                CardStartIndex = 0,
                Column = 10,
                Row = 15,
                GameSeconds = 180
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 24;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Left,
                CardChangeRange = 18,
                CardStartIndex = 0,
                Column = 10,
                Row = 15,
                GameSeconds = 180
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 25;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Right,
                CardChangeRange = 18,
                CardStartIndex = 2,
                Column = 10,
                Row = 15,
                GameSeconds = 190
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 26;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.LeftRight,
                CardChangeRange = 19,
                CardStartIndex = 0,
                Column = 10,
                Row = 15,
                GameSeconds = 190
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 27;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Top,
                CardChangeRange = 19,
                CardStartIndex = 1,
                Column = 10,
                Row = 15,
                GameSeconds = 190
            };
            StageInfos.Add(stageTypePre + index, info);

            index = 28;
            info = new StageInfo()
            {
                ArrangeType = GameArrangeType.Bottom,
                CardChangeRange = 20,
                CardStartIndex = 0,
                Column = 10,
                Row = 15,
                GameSeconds = 190
            };
            StageInfos.Add(stageTypePre + index, info);

            #endregion
        }

        public void SaveStageDatas()
        {
            IsolatedStorageSettings.ApplicationSettings[STAGE_DATA_KEY] = StageDatas;
            IsolatedStorageSettings.ApplicationSettings.Save();
        }
    }
}
